﻿<div class="form-horizontal" ms-controller="KSGL">
    <div style="margin: 0 80px;">
        <div>
            <ul class="clearfix" style="display: block;padding:0">
                <li class="add-item add-width fl-left">
                    <label class="add-item-label"><i>*</i>考试安排名称</label>
                    <div class="add-ic">
                        <input type="text" class="form-control  szhl_require" ms-duplex="modelData.KSName">
                    </div>
                </li>
                <li class="add-item add-width fl-right">
                    <label class="add-item-label"><i>*</i>考试时间</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_form_date_time  szhl_require" ms-duplex="modelData.KSDate">
                    </div>
                </li>
                <li class="add-item add-width fl-left">
                    <label class="add-item-label"><i>*</i>时长(分钟)</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_Int  szhl_require" ms-duplex="modelData.KSSC">
                    </div>
                </li>
                <li class="add-item add-width fl-right">
                    <label class="add-item-label">可延长时间</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_Int" ms-duplex="modelData.YCSY">
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>考试试卷</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require szhl_select">
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>阅卷老师</label>
                    <div class="add-ic">
                        <input type="text" ms-duplex="modelData.YJTeacher" signle="Y" class="form-control szhl_require szhl_getPeoples" />
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>考试人员</label>
                    <div class="add-ic">
                        <input type="text" ms-duplex="modelData.KSUser" class="form-control szhl_require szhl_getPeoples" />
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label"><i>*</i>考试地址</label>
                    <div class="add-ic">
                        <input type="text" class="form-control szhl_require" ms-duplex="modelData.Address" />
                    </div>
                </li>
                <li class="add-item add-widthall">
                    <label class="add-item-label">考试安排描述</label>
                    <div class="add-ic">
                        <textarea class="span2  szhl_UEEDIT" id="ksap" rows="5" ms-duplex="modelData.Remark"></textarea>
                    </div>
                </li>
            </ul>
        </div>

    </div>
</div>

<script>
    var tempmodel = avalon.define({
        $id: "KSGL",
        name: "考试安排",
        ColumnData: [],
        modelData: { "KSName": "", "SJID": "", "KSSC": "", "YCSY": "0", "KSDate": "", "KSUser": "", "Address": "", "Remark": "", YJTeacher: "" },
        iswf: false,//是否属于流程表单
        inittemp: function (strId) {
            if (strId) {
                //编辑加载数据
                $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_GETKSAPMODEL', { P1: strId }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        tempmodel.modelData = resultData.Result;
                        setTimeout(" ComFunJS.initForm()", 500)
                    }
                })
            } else {
                ComFunJS.initForm();
            }
            $.getJSON('/API/VIEWAPI.ashx?Action=KSGL_GETSJFBLIST', { P1: strId }, function (resultData) {
                if (resultData.ErrorMsg == "") {
                    tempmodel.ColumnData = resultData.Result;
                }
                setTimeout("tempmodel.sj()", 1000);
            })
        },//初始化
        SaveData: function (callback) {
            var data = tempmodel.modelData.$model;
            var modelValue = JSON.stringify(data);
            $.post("/API/VIEWAPI.ashx?ACTION=KSGL_ADDKSAP", { P1: modelValue }, function (result) {
                return callback.call(this, $.parseJSON(result));
            });
        }, sj: function () {
            tempmodel.ColumnData.forEach(function (item) {
                if (item.ID == tempmodel.modelData.SJID) {
                    $(".szhl_select").val(item.ID);
                }
            })
            if ($(".szhl_select").length > 0) {
                var tabsel = $(".szhl_select").YanSelect({
                    valueindex: 0,//值对应列
                    textindex: 1,
                    isCanAdd: false,
                    width: "800px",
                    dataobj: tempmodel.ColumnData,
                    columns: [{ "fieldname": "ID", "text": "序号" }, { "fieldname": "SJName", "text": "试卷名称" }, { "fieldname": "SJDescribe", "text": "试卷说明" }, { "fieldname": "KSSC", "text": "考试时长(分钟)" }],
                    afterSelect: function (dom) {
                        tempmodel.modelData.SJID = dom.attr('dataid')
                    }
                });
            }
        }
    });
</script>